<!doctype html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>服装企业人事管理系统</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <!-- <link rel="stylesheet" href="./css/theme5.css"> -->
    <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body class="index">
<div th:replace="admin/commons/bar::topbar"></div>

<div th:replace="admin/commons/bar::sidebar"></div>

<div class="page-content">
    <div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="false">
        <div class="layui-tab-item layui-show">
            <div class="layui-row">
                <div>
                    <div class="layui-form-item">
                        <label for="oldpwd" class="layui-form-label">
                            <span class="x-red">*</span>原密码
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" name="oldpwd" id="oldpwd" required="" lay-verify="required"
                                   autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">
                            <span class="x-red">*</span>之前登录系统的密码
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="newpwd" class="layui-form-label">
                            <span class="x-red">*</span>新密码
                        </label>
                        <div class="layui-input-inline">
                            <input type="password" name="newpwd" id="newpwd" required="" lay-verify="pass"
                                   autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">
                            6到16个字符
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="checkpwd" class="layui-form-label">
                            <span class="x-red">*</span>确认密码
                        </label>
                        <div class="layui-input-inline">
                            <input type="password" name="checkpwd" id="checkpwd" required="" lay-verify="repass"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="updpwd" class="layui-form-label">
                        </label>
                        <button  class="layui-btn" lay-filter="edit" type="submit" id="updpwd">
                            修改
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="page-content-bg"></div>
<style id="theme_style"></style>
<script>
    $(document).ready(function () {
        $("#updpwd").click(function () {
            var oldpwd = $("#oldpwd").val();
            var newpwd = $("#newpwd").val();
            var checkpwd = $("#checkpwd").val();
            if(oldpwd === '' || newpwd === '' || checkpwd === '') {
                alert("表单内容不能为空");
                return false;
            }
            if(newpwd !== checkpwd) {
                alert("前后密码不一致，请重新确认密码！");
                return false;
            }
            if(newpwd === oldpwd) {
                alert("新密码不能和旧密码一样!");
                return false;
            }
            $.post(
                "/updpwd",
                {
                    oldpwd:oldpwd,
                    newpwd:newpwd
                },
                function(data,status){
                    if (JSON.stringify(data).match("原密码填写错误")) {
                        alert(data);
                        window.location.href="/updpwd";
                    } else {
                        alert(data);
                        window.location.href="/login.html";
                    }
                }
            );
        });
    });
</script>
</body>
</html>